<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<title>主页</title>
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.5.3/themes/metro-gray/easyui.css">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.5.3/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/jquery-easyui-1.5.3/themes/IconExtension.css">
	<script src="${pageContext.request.contextPath}/js/jquery-easyui-1.5.3/jquery.min.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/js/jquery-easyui-1.5.3/jquery.easyui.min.js" type="text/javascript"></script>
</head>
<body class="easyui-layout" data-options="fit:'true'">
	<div data-options="region:'north',split:true" style="height:110px; 
		background-image:url('${pageContext.request.contextPath}/images/1.jpg'); 
		background-repeat:no-repeat; background-size:100%;">
		<img src="${pageContext.request.contextPath}/images/logo.png">
		<div style="float:right; margin-top:6em;">
			<a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'icon-lightbulb'">
				<span style="color: red;">${sessionScope.USER.userName}</span>欢迎您！
			</a>
			<a href="javascript:void(0);" class="easyui-linkbutton" 
				data-options="iconCls:'icon-wrench_orange', onClick:function() {
				$.messager.alert('提示信息','修改密码功能待完成','info');}">修改密码
			</a>
			<a href="javascript:void(0);" class="easyui-linkbutton" 
				data-options="iconCls:'icon-control_power', onClick:function() {
				window.location.href='${pageContext.request.contextPath}/logout'}">安全退出
			</a>
		</div>
	</div>
    <div data-options="region:'west',title:'导航菜单',split:true,collapsible:false" style="width:200px;">
    	<div id="guide_menu" class="easyui-accordion" data-options="fit:true, border:false"></div>
    </div>
    <div data-options="region:'center'" style="padding:5px;background:#eee;">
    	<div id="content_tabs"></div>
    </div>
</body>

<script type="text/javascript">
	$(function() {
		initGuideMenu();
		initContentTabs();
	});
	
	/** 初始化内容面板  */
	function initContentTabs() {
		$("#content_tabs").tabs({
			fit : true
		});
		$("#content_tabs").tabs("add", {
			id : "SY",
			iconCls : "icon-home",
			title : "首页",
			content : "<h1 style='font-family:隶书'>投诉管理系统欢迎您！</h1>"
		});
	}
	
	/** 初始化菜单  */
	function initGuideMenu() {
		$.ajax({
			url : "${pageContext.request.contextPath}/home/initGuideMenu",
			type : "POST",
			dataType : "JSON",
			success : function(data) {
				$.each(data.roleList, function(i, roleHome) {
					$.each(roleHome.privilegeList, function(j, privilege) {
						if (privilege.privilegeType == 1) {
							var menu1Attr = {};
							menu1Attr.id = privilege.privilegeId+"_"+privilege.privilegeCode;
							menu1Attr.title = privilege.privilegeName;
							menu1Attr.iconCls = privilege.icon;
							menu1Attr.selected = false;
							menu1Attr.border = false;
							$("#guide_menu").accordion("add", menu1Attr);
							$("#"+menu1Attr.id).html("<ul id='"+privilege.privilegeCode+"'></ul>");
							$("#"+privilege.privilegeCode).tree({
								url : "${pageContext.request.contextPath}/home/initGuideMenu2",
								queryParams : {pid : privilege.privilegeId},
								animate : true,
								lines : true,
								onClick : function(node) {
									if (node.children.length > 0) {
										return;
									}
									if ($("#content_tabs").tabs("exists", node.text)) {
										$("#content_tabs").tabs("select", node.text);
									} else {
										$("#content_tabs").tabs("add", {
											id : node.attributes.privilegeCode,
											iconCls : node.iconCls,
											title : node.text,
											closable : true,
											href : "${pageContext.request.contextPath}"+node.attributes.url
										});
									}
								}
							});
						}
					});
				});
			},
			error : function() {
				$.messager.alert("异常信息", "服务器异常，请稍后再试！", "error");
			}
		});
	}
</script>
</html>
